#include<iostream>
#include<vector>
using namespace std;

struct qujian{
  int l,r;
};

int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  vector<int> qzh(n+1,0);
  for(int i=1;i<=n;i++){
    qzh[i]=qzh[i-1]+v[i-1];
  }
  int m;
  cin>>m;
  vector<qujian> q(m);
  for(int i=0;i<m;i++){
    cin>>q[i].l>>q[i].r;
    cout<<qzh[q[i].r]-qzh[q[i].l-1]<<endl;
  }

  return 0;
}